package demo3;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 87111
 * Date: 2025-06-24
 * Time: 11:32
 */
public class InnerClassExercise {
    public static void main(String[] args) {
        OuterClass outerClass = new OuterClass();
        //方法一：
        OuterClass.InnerClass innerClass = outerClass.new InnerClass();
        innerClass.print();
        //方法二：
        OuterClass.InnerClass innerClass1 = outerClass.getClass01();
        innerClass1.print();
    }
}

class OuterClass {

    class InnerClass {
        private String name;
        public void print() {
            System.out.println("haha");
        }
    }
    public InnerClass getClass01() {
        return new InnerClass();
    }
}
